package ie.dcu.spca.view.product;

import android.app.Activity;
import android.content.Intent;
import android.widget.EditText;

public class BarcodeScanResultActivity extends Activity {

    protected EditText scanResultTextEdit;
    protected String scanResultContents;
    protected String scanResultFormat;

    public EditText getScanResultTextEdit() {
        return scanResultTextEdit;
    }

    public void setScanResultTextEdit(EditText scanResultTextEdit) {
        this.scanResultTextEdit = scanResultTextEdit;
    }

    public String getScanResultContents() {
        return scanResultContents;
    }

    public void setScanResultContents(String scanResultContents) {
        this.scanResultContents = scanResultContents;
    }

    public String getScanResultFormat() {
        return scanResultFormat;
    }

    public void setScanResultFormat(String scanResultFormat) {
        this.scanResultFormat = scanResultFormat;
    }

    @Override
    public void onActivityResult(int requestCode, int resultCode, Intent intent) {
        if (requestCode == 0) {
            if (resultCode == RESULT_OK) {
                scanResultContents = intent.getStringExtra("SCAN_RESULT");
                scanResultFormat = intent.getStringExtra("SCAN_RESULT_FORMAT");
                // Handle successful scan
            } else if (resultCode == RESULT_CANCELED) {
                scanResultContents = "";
            }
        }
        if (scanResultTextEdit != null)
            scanResultTextEdit.setText(scanResultContents);
    }
}
